#ifndef CONNECTION_SERVER_INCLUDED
#define CONNECTION_SERVER_INCLUDED

#include <string>
#include <pthread.h>
#include "ThreadService.h"
#include "com.pb.h"

using namespace std;

class serverTCP;

class socketTCP : public ThreadService
{
	void processThreadProcess();
public:
	bool sendString(com::Block const& block);
	socketTCP(int socket, serverTCP *server);
	bool isActive()
	{
		return m_active;
	}
private:
	int m_socket;
	bool m_active;
	serverTCP *m_server;
	pthread_mutex_t m_send_block_mutex;
};

class serverTCP : public ThreadService
{
	void processThreadProcess();
public:
	serverTCP(int port);
	virtual void dataReceive(com::Block const& block, socketTCP* socket)=0;

private:
	int m_port;
	pthread_t* m_thread;
};

#endif
